////////////////////////////////////////////////////////////////////////////
//
//  Crytek Engine Source File.
//  Copyright (C), Crytek Studios, 2001-2004.
// -------------------------------------------------------------------------
//  File name:   AxisHelper.h
//  Version:     v1.00
//  Created:     29/10/2004 by Timur.
//  Compilers:   Visual Studio.NET 2003
//  Description: 
// -------------------------------------------------------------------------
//  History:
//
////////////////////////////////////////////////////////////////////////////

#ifndef __AxisHelper_h__
#define __AxisHelper_h__
#pragma once


struct DisplayContext;
struct HitContext;


//////////////////////////////////////////////////////////////////////////
// Helper Extended Axis object.
//////////////////////////////////////////////////////////////////////////
class CAxisHelperExtended
{
public:
	CAxisHelperExtended();
	void DrawAxes(DisplayContext &dc, const Matrix34& matrix);

private:
	void DrawAxis(DisplayContext &dc, const Vec3& vDirAxis, const Vec3& vUpAxis, const Vec3& col);

private:
	Matrix34 m_matrix;
	Vec3 m_vPos;
	struct IPhysicalEntity* m_pSkipEntity;
	int m_numSkipEnts;
	std::vector<CBaseObject*> m_objects;
	CBaseObject* m_pCurObject;
	DWORD m_dwLastUpdateTime;

	const float m_fMaxDist;
};


//////////////////////////////////////////////////////////////////////////
// Helper Axis object.
//////////////////////////////////////////////////////////////////////////
class SANDBOX_API CAxisHelper
{
public:
	enum EHelperMode
	{
		MOVE_MODE    = 0x1,
		SCALE_MODE   = 0x2,
		ROTATE_MODE  = 0x4,
		SELECT_MODE  = 0x8,
	};

	CAxisHelper();

	void SetMode( int nModeFlags );
	void DrawAxis( const Matrix34 &worldTM, DisplayContext &dc );
	void DrawExtendedAxis( DisplayContext &dc, const Vec3& vDirAxis, const Vec3& vUpAxis, const Vec3& col, const std::vector<CBaseObject*>& objects );
	bool HitTest( const Matrix34 &worldTM, HitContext &hc );

	void SetHighlightAxis( int axis ) { m_highlightAxis = axis; };
	int  GetHighlightAxis() const { return m_highlightAxis; };

private:
	void Prepare( const Matrix34 &worldTM,CViewport *view );
	float GetDistance2D( CViewport *view,CPoint p,Vec3 &wp );

	int m_nModeFlags;
	int m_highlightAxis;
	int m_highlightMode;
	int m_currentMode;

	float m_fScreenScale;
	bool m_bNeedX;
	bool m_bNeedY;
	bool m_bNeedZ;
	float m_size;
	Matrix34 m_matrix;

	CAxisHelperExtended m_axisHelperExtended;
};

#endif // __AxisHelper_h__

